/*
 * @Author: Aro
 * @Date: 2024-01-29 00:04:46
 */
import 'package:fluro/fluro.dart';
import 'package:flutter_baseui/routers/i_fluro_router.dart';
import 'package:flutter_baseui/views/router_screen/demo/model/complex_params_model.dart';
import 'package:flutter_baseui/views/router_screen/demo/router_complex_params_demo.dart';
import 'package:flutter_baseui/views/router_screen/demo/router_params_demo.dart';
import 'package:flutter_baseui/views/router_screen/router_screen.dart';

class RouterScreenRouter implements IFluroRouter {
  static String routerPage = '/routeHome';
  static String routerParamsPage = '/routerParamsDemo';
  static String routerComplexParamsPage = '/routerComplexParamsDemo';
  @override
  void initRouter(FluroRouter router) {
    router.define(
      routerPage,
      handler: Handler(handlerFunc: (_, __) => const RouterScreen()),
    );
    router.define(
      routerParamsPage,
      handler: Handler(handlerFunc: (_, Map<String, List<String>> params) {
        String userId = params['userId']!.first;
        return RouterParamsDemo(userId: userId);
      }),
    );
    router.define(
      routerComplexParamsPage,
      handler: Handler(handlerFunc: (context, __) {
        final args = context!.settings!.arguments as ComplexParamsModel;
        return RouterComplexParamsDemo(
          username: args.username,
          id: args.id,
        );
      }),
    );
  }
}
